<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="utf-8">

<!--表示使用IE最新的渲染模式进行解析-->
<meta http-equiv="X-UA-Compatible" content="IE=edge">

<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- 上述3个meta标签*必须*放在最前面，任何其他内容都*必须*跟随其后！ -->
<title>黄河科技学院附属大酒店宾馆客房管理系统</title>

<!-- Bootstrap -->
<link href="${pageContext.request.contextPath}/css/bootstrap.min.css" rel="stylesheet">
<!-- 如果IE版本小于9，加载以下js,解决低版本兼容问题 -->
<!--[if lt IE 9]>
      <script src="https://cdn.bootcss.com/html5shiv/3.7.3/html5shiv.min.js"></script>
      <script src="https://cdn.bootcss.com/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->

<script src="${pageContext.request.contextPath}/js/jquery-1.12.4.min.js"></script>
<script src="${pageContext.request.contextPath}/js/jquery.js"></script>
<script src="${pageContext.request.contextPath}/js/bootstrap.min.js"></script>
<script src="${pageContext.request.contextPath}/js/confirm.js"></script>
<style type="text/css">
th {
	text-align: center;
}
.current{
	color: purple;
}

</style>





</head>
<body>
<nav class="navbar-inverse">
	<div class="container">
		<!-- Brand and toggle get grouped for better mobile display -->
		<div class="navbar-header">
			<a class="navbar-brand" href="#">宾馆客房管理系统 : </a>
		</div>
		<div class="collapse navbar-collapse"
			 id="bs-example-navbar-collapse-9">
			<ul class="nav navbar-nav">
				<li class="active" ><a href="${pageContext.request.contextPath}/room/list.do">客房管理</a></li>
				<li ><a href="${pageContext.request.contextPath}/order/list.do">订单管理</a></li>
				<li ><a href="${pageContext.request.contextPath}/customer/list.do">客户管理</a></li>
				<li ><a href="${pageContext.request.contextPath}/user/list.do">员工管理</a></li>
				<li ><a href="${pageContext.request.contextPath}/behind/Mouth.jsp">月营业额统计</a></li>
				<li ><a href="${pageContext.request.contextPath}/behind/Year.jsp">年营业额统计</a></li>
			</ul>
			<p class="navbar-text navbar-right">
				<span>${username}</span> <i class="glyphicon glyphicon-log-in" aria-hidden="true"></i>&nbsp;&nbsp;
				<a href="${pageContext.request.contextPath}/exit.do" class="navbar-link">退出</a>
			</p>
		</div>
	</div>
</nav>


</div>
		
	</nav>

	<div class="jumbotron" style="padding-top: 15px;padding-bottom: 15px;">
		<div class="container">
			<h2>客房管理</h2>
		</div>
	</div>


	<div class="container">

		<div class="row">
			<div class="col-md-4">
				<a href="${pageContext.request.contextPath}/behind/room/addRoom.jsp">
					<button type="button" class="btn btn-success">添加客房</button>
				</a>
				 <button id="delAll"  type="button" class="btn btn-danger">批量删除</button>
			</div>
			<div class="col-md-8">
				<form id="form" class="navbar-form navbar-right" action="${pageContext.request.contextPath}/room/list.do" >
					<input id="hid"  name="pageNum" value="" type="hidden">
					<input type="text" name="type" value="${map.type}" class="form-control" placeholder="房间类型">
					<div class="btn-group">
						<input type="text" name="RoomNum" value="${map.RoomNum}"  class="form-control" placeholder="房间号">
					</div>
					<div class="btn-group">
						<input type="text" name="status" value="${map.status}"  class="form-control" placeholder="客房状态">
<%--						<select name="status" class="form-control">--%>
<%--							<option value="已预定" ${map.status == "已预定" ? "selected":""}>已预定</option>--%>
<%--							<option value="未预定" ${map.status == "未预定" ? "selected":""}>未预定</option>--%>
<%--						</select>--%>

					</div>
					<button type="submit" class="btn btn-primary">查询</button>
					<a href="${pageContext.request.contextPath}/room/list.do">
						<button type="button" class="btn btn-warning">清空</button>
					</a>
				</form>

			</div>
			<!-- 查询相关组件 -->

		</div>
	</div>

	<div class="container" style="margin-top: 20px;">
		<form action="delBatchVideos.action" method="post">
			<table class="table table-bordered table-hover"
				style="text-align: center;table-layout:fixed">
				<thead>
					<tr id="t1">
						<th style="width:3%"><input type="checkbox" id="checkall" ></th>
						<th style="width:5%">序号</th>
						<th style="width:7%">房间号</th>
						<th style="width:10%;">房间类型</th>
						<th style="width:7%;">状态</th>
						<th style="width:7%;">可住人数</th>
						<th style="width:10%;">开始预定时间</th>
						<th style="width:10%;">客人离开时间</th>
<%--						<th >图片</th>--%>
						<th>详情</th>
						<th>更新</th>
						<th>删除</th>
					</tr>
				</thead>
				<tbody>
					<c:forEach items="${rooms}" var="room" varStatus="status">
						<tr class="active">
							<td><input type="checkbox" value="${room.id}"  name="check"></td>
<%--							<td>${status.index+1}</td>--%>
							<td>${room.id}</td>
							<td>${room.roomnum}</td>
							<td>${room.type}</td>
							<td>${room.status}</td>
							<td>${room.peoplenum}</td>
							<td>${room.startTime}</td>
							<td>${room.endTime}</td>
<%--							<td ><img src="${room.imageurl}" alt="" class="img-rounded"></td>--%>
								<%--详情--%>
							<th><a href="${pageContext.request.contextPath}/room/lookRoom.do?id=${room.id}" ><span class="glyphicon glyphicon-fullscreen"></span></a></th>
								<%--修改--%>
							<th><a href="${pageContext.request.contextPath}/room/lookRoom2.do?id=${room.id}" ><span class="glyphicon glyphicon-pencil"></span></a></th>
								<%--删除--%>
							<th><a href="#" onclick="deleteById(${room.id})"><span  class="glyphicon glyphicon-trash"></span></a></th>
						</tr>

					</c:forEach>
				</tbody>
			</table>
		</form>

	<nav aria-label="..." style="text-align: right">
		<ul class="pagination pagination-lg">
<%--			class="disabled"--%>
			<li><a onClick="tooKeywordFind(${pageInfo.firstPage});"  href="#" > 第一页</a></li>
			<li ><a href="#" onClick="tooKeywordFind(${pageInfo.prePage});"  ><span class="glyphicon glyphicon-chevron-left"></span></a></li>
			<c:forEach begin="1"  end="${pageInfo.pages }"  step="1" var="i">
				<li class="${i == pageInfo.pageNum ? 'active' : ''}"><a onclick="tooKeywordFind(${i});"  href="#"  > ${i}</a></li>
			</c:forEach>
			<li><a href="#" onclick="tooKeywordFind(${pageInfo.nextPage});" ><span class="glyphicon glyphicon-chevron-right"></span></a></li>
			<li><a href="#" onclick="tooKeywordFind(${pageInfo.lastPage});" >最后一页</a></li>
			<li><span class='current'>共${pageInfo.total }条记录</span></li>
			<li><span class='current'> ${ pageInfo.pageNum}/${pageInfo. pages}页</span></li>
		</ul>
	</nav>
	</div>
</body>

<script type="text/javascript">
	function tooKeywordFind(pageNum) {
		//获得输入框对象
		var hid = document.getElementById("hid");
		$("#hidPageSize").val($("#changeSize").val());
		//给输入框的value赋值
		hid.value = pageNum;
		//获得form表单对象
		var form = document.getElementById("form");
		//让表单提交
		form.submit();
		//组织a标签中的href继续跳转
		return false;
	}
</script>
</html>

<script type="text/javascript">

	$("#checkall").change(function() {
		//alert("多选");
		//var $ch = $("#checkall");
		//var $chArr = $(".check");
		//alert($chArr.length);
		var alls = document.getElementsByName("check");
		var ch = document.getElementById("checkall");
		if (ch.checked) {
			for (var i = 0; i < alls.length; i++) {
				alls[i].checked = true;
			}
		} else {
			for (var i = 0; i < alls.length; i++) {
				alls[i].checked = false;
			}
		}
	});

	$("#delAll").click(function(){
		//alert("批量删除");
		var alls = document.getElementsByName("check");
		var ids = new Array();
		for (var i = 0; i < alls.length; i++) {
			if (alls[i].checked) {
				ids.push(alls[i].value);
			}
		}
		alert("要批量删除"+ids.length+"条数据");
		$("#delNum").val(ids.length);
		if (ids.length > 0) {
			if (confirm("确认操作?")) {
				//window.location.href = "video/deleteAll.do?ids=" + ids;
				//window.location = "http://localhost:8080/HIS/registration/deleteRegistration.do?medicalRecord="+id;
				window.location = "http://localhost:8080/room/deleteAll.do?ids="+ids;
				alert("批量删除成功!");
			}
		} else {
			alert("请选中要操作的项");
		}
	});

	function deleteById(id) {
		//alert("deleteById函数生效");
		if (confirm("确认删除?")) {
			window.location = "http://localhost:8080/room/delete.do?id=" + id;
			alert("删除成功!");
		}
	}
</script>

